package com.th.config.rabbitmq;

import com.th.common.constants.AuthConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ErrorRua
 * @date 2023/06/24
 * @description:
 */


@Configuration
public class DeclareAuthRabbitConfig {
    @Bean
    public TopicExchange authExchange(){
        return new TopicExchange(AuthConstants.AUTH_EXCHANGE, true, false);
    }

    @Bean
    public Queue authQueue(){
        return new Queue(AuthConstants.AUTH_IDENTIFY_QUEUE, true);
    }

    @Bean
    public Binding bindingAuth(Queue authQueue, TopicExchange authExchange){
        return BindingBuilder.bind(authQueue).to(authExchange).with(AuthConstants.AUTH_IDENTIFY_KEY);
    }

    @Bean
    public Queue authInternalMessageQueue(){
        return new Queue(AuthConstants.AUTH_INTERNAL_MESSAGE_QUEUE, true);
    }

    @Bean
    public Binding bindingAuthInternalMessage(Queue authInternalMessageQueue, TopicExchange authExchange){
        return BindingBuilder.bind(authInternalMessageQueue).to(authExchange).with(AuthConstants.AUTH_INTERNAL_MESSAGE_KEY);
    }

    @Bean
    public Queue authMailMessageQueue(){
        return new Queue(AuthConstants.AUTH_MAIL_MESSAGE_QUEUE, true);
    }

    @Bean
    public Binding bindingAuthMailMessage(Queue authMailMessageQueue, TopicExchange authExchange){
        return BindingBuilder.bind(authMailMessageQueue).to(authExchange).with(AuthConstants.AUTH_MAIL_MESSAGE_KEY);
    }

}
